<template>

  <div class="app-container">

    <h2 style="text-align: center;">留言回答</h2>

    <el-form label-width="120px">
        <!-- 课程简介 TODO -->
        <el-form-item label="问题正文">
            <tinymce :height="300" v-model="messageInfo.answerMessage"/>
        </el-form-item>

        <el-form-item>
            <el-button :disabled="saveBtnDisabled" type="primary" @click="addMessageAnswer">确认</el-button>
        </el-form-item>
        </el-form>
  </div>
</template>
<script>
import message from '@/api/tax/message'
import Tinymce from '@/components/Tinymce'  //引入富文本组件

export default {
    // 声明组件
    components: {Tinymce},
    data() {
        return {
            saveBtnDisabled:false,
            messageInfo:{
                id: '',
                answerMessage: ''
            },
            BASE_API: process.env.BASE_API, // 接口API地址
        }
    }, 
    created() {
        // 获取路由的ID值
        if (this.$route.params && this.$route.params.id) {
            this.messageInfo.id = this.$route.params.id
        }
    },
    methods: {
        addMessageAnswer() {
            message.addMessageAnswer(this.messageInfo)
                .then(response => {
                    //提示
                    this.$message({
                        type: 'success',
                        message: '回答成功!'
                    });
                    this.$router.push({path:'/message/table'})
                })
        }
    }
}
</script>
<style scoped>
/* scoped表示该样式只在当前页面显示 */
.tinymce-container {
  line-height: 29px;
}
</style>